package cn.felord.command;

import java.util.LinkedList;
import java.util.Queue;

public class CompositeCommand implements Command {

    private Queue<Receiver> queue = new LinkedList<>();

    public void addReceiver(Receiver receiver) {
        queue.add(receiver);
    }

    @Override
    public void execute() {
        while (!queue.isEmpty()) {
            Receiver poll = queue.poll();
            poll.doAction();
        }
    }
}
